package com.zcwin.runner.jmx;

import org.apache.log4j.PropertyConfigurator;

import com.zcwin.runner.model.SendSmsService;


public class SendSmsRunner  extends DefaultMyRunner
{
    private static int countNum = 0;
    public void run()
    {
        int rtnNum = 0;
        SendSmsService sendInfoImpl = new SendSmsService();
        while(true)
        {
            try
            {
                sendInfoImpl.sendSmsProcess();
                sendInfoImpl.querySmsProcess();
                rtnNum+=2;
            } catch (Exception e1) {
                e1.printStackTrace();
            }

            try
            {
                if(rtnNum == 0 || countNum > this.getQueuelength())
                {
                    countNum = 0;
                    Thread.sleep(this.getiWaitTime());
                }
                else
                {
                    countNum++;
                }
            } catch (InterruptedException e)
            {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
    	//String home = SendSmsRunner.class.getResource("/").getPath().substring(1);
    	String home = System.getProperty("home");
        System.setProperty("RUNNER.HOME", home);
        System.setProperty("user.timezone", "GMT+08");
        PropertyConfigurator.configure(System.getProperty("RUNNER.HOME") + "/config/log4j.properties");
        SendSmsRunner t = new SendSmsRunner();
        t.run();
    }
}

